package GUI;

import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.Point;

import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import java.awt.GridLayout;
import javax.swing.BoxLayout;
import com.jgoodies.forms.layout.FormLayout;
import com.jgoodies.forms.layout.ColumnSpec;
import com.jgoodies.forms.layout.RowSpec;
import com.jgoodies.forms.factories.FormFactory;
import java.awt.Dimension;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.Dialog.ModalityType;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import javax.swing.SwingConstants;

public class ConfirmDialog extends JDialog {

	private final JPanel contentPanel = new JPanel();
	public Boolean result = false;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		try {
			ConfirmDialog dialog = new ConfirmDialog("Are you OK?", new Point(400,200));
			dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
			dialog.setVisible(true);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Create the dialog.
	 */
	public ConfirmDialog( String mess, Point point) {
		setResizable(false);
		setModalityType(ModalityType.APPLICATION_MODAL);
		setModal(true);
		setTitle("Message");

		setBounds(point.x, point.y , 403, 153);
		getContentPane().setLayout(new BorderLayout());
		contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5));
		getContentPane().add(contentPanel, BorderLayout.CENTER);
		contentPanel.setLayout(null);
		{
			JButton btnNo = new JButton("No");
			btnNo.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					result = false;
					setVisible(false);
				}
			});
			btnNo.setBounds(215, 94, 59, 23);
			contentPanel.add(btnNo);
			btnNo.setActionCommand("Cancel");
		}
		{
			JButton btnYes = new JButton("Yes");
			btnYes.addActionListener(new ActionListener() {
				public void actionPerformed(ActionEvent e) {
					result = true;
					setVisible(false);
				}
			});
			btnYes.setBounds(119, 94, 65, 23);
			contentPanel.add(btnYes);
			btnYes.setActionCommand("OK");
			getRootPane().setDefaultButton(btnYes);
		}
		
		JLabel labelMess = new JLabel(mess);
		labelMess.setHorizontalAlignment(SwingConstants.CENTER);
		labelMess.setFont(new Font("Tahoma", Font.BOLD, 13));
		labelMess.setBounds(10, 11, 377, 72);
		contentPanel.add(labelMess);
	}
}
